﻿using System;
using ApplicationLibrary;
using ApplicationLibrary.ExtendedControls;
using ApplicationLibrary.SqlConnector;
using Plumber.Masters.ModuleData;

namespace Plumber.Masters.Library
{
    public class MasterTypeComboBox : DBComboBox
    {
        public DRMasterType dRMasterType;

        public MasterTypeComboBox()
        {
        }

        public void AttachDataReader(DataReaderUpdater dr, bool alsoNull = false)
        {
            dRMasterType = new DRMasterType(DRMasterType.Module.All);
            base.AttachDataReader<string>(dr, PL_MasterType.Code, PL_MasterType.Description, alsoNull);
            dRMasterType.Find(cbbManager.GetValue<string>());
        }

        protected override void OnSelectedIndexChanged(EventArgs e)
        {
            if (!string.IsNullOrEmpty(GetValue<string>()))
                dRMasterType.Find(GetValue<string>());

            base.OnSelectedIndexChanged(e);
        }
    }
}